<%-- 
    Document   : main
    Created on : 23/09/2014, 22:20:02
    Author     : leoomoreira
--%>

<%@page import="storymotion.storytelling.Storytelling"%>
<%@page import="storymotion.keyword.Keyword"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="storymotion.photo.Photo"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="header.jsp" %>
<% SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); %>
<br/>
<% if (request.getAttribute("message") != null) {%>
<div id="message"><%= request.getAttribute("message").toString()%></div>
<% }%>
<div id="content_table">
    <div id="content_row">
        <div id="content_cell">
            <div id="myphotos">My Photos</div>
            <div><input type="button" id="addPhoto" value="Add Photo" /></div>
                <% if (request.getAttribute("photoList") != null) {
                        List<Photo> photoList = (List<Photo>) request.getAttribute("photoList");
                %>
            <div>
                <%
                    for (Photo p : photoList) {
                %>
                <div><img src="RenderPhoto?photoId=<%= p.getId()%>" id="photoFrame"/></div>
                <div class="photoUploadInfo"><%= dateFormat.format(p.getDate())%></div>
                <div class="photoUploadInfo separation"><%= p.getName()%></div>
                <div class="photoUploadInfo removeSeparation"><a href="PhotoUploadDelete?photoId=<%= p.getId()%>">Remove</a></div>
                <% if (request.getAttribute("keywordsList_" + p.getId()) != null) { %>
                <div class="divSeparator">Keywords: 
                    <%
                        List<Keyword> keywords = (List<Keyword>) request.getAttribute("keywordsList_" + p.getId());
                        for (Keyword k : keywords) {
                    %>
                    <div class="keywords"><%= k.getKeyword()%>; </div>
                    <%
                        }
                    %>
                </div>
                <%  } %>
                <%  } %>
            </div>
            <%    }%>
        </div>
        
        <div id="content_cell">
            <div id="mystorytellings">My Storytellings</div>
            <div><input type="button" id="createStorytelling" value="Create Storytelling" /></div>
                <% if (request.getAttribute("storytellingList") != null) {
                        List<Storytelling> storytellingList = (List<Storytelling>) request.getAttribute("storytellingList");
                %>
            <div>
                <%
                    for (Storytelling s : storytellingList) {
                %>
                <div><img src="RenderStorytelling?storytellingId=<%= s.getId()%>" id="photoFrame" /></div>        
                <div class="photoUploadInfo"><%= dateFormat.format(s.getDate())%></div>
                <div class="photoUploadInfo separation"><%= s.getName()%></div>
                <div class="photoUploadInfo removeSeparation"><a href="StorytellingDelete?storytellingId=<%= s.getId()%>">Remove</a></div>
                <div class="divSeparator"></div>
                <%  } %>
            </div>
            <%    }%>
        </div>
    </div>
</div>
<%@include file="footer.jsp" %>
<script src="js/main.js"></script>